using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class so_LocationMap : EntityTypeConfiguration<so_Location>
    {
        public so_LocationMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Name, t.Id });

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(3);

            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            // Table & Column Mappings
            this.ToTable("so_Location");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Id).HasColumnName("Id");
        }
    }
}
